#ifndef __TFLJOURNEYPLANNERQUERY__
#define __TFLJOURNEYPLANNERQUERY__

#include "HTTPUtils.h"
#include <euserhl.h>
#include "ActiveTarget.h"
#include <lbsposition.h>
#include <http.h>
#include <es_sock.h>
#include <Function.h>
#include "JourneyPlanner.h"


class CTFLJourneyPlannerQuery : public CBase
	{

public:
	
	typedef scalp::CFunction< void(CTFLJourneyPlannerQuery*, TInt, TInt, CJourneyPlannerOutput*) > TCallbackType;
	
	LManagedPtr<TCallbackType> iCallback;
	LManagedPtr<CDeflateDecompressor> iDeflateDecompressor;
	
	RHTTPSession iHTTPSession;
	void SetConnectionInfoL(const RConnection& aConnection, const RSocketServ& aSocketServ);
	void CloseConnectionL();
	void SubmitL(const TDesC8& aStopOrigin, const TDesC8& aStopDestination, TInt aTravelOption, CTFLJourneyPlannerQuery::TCallbackType* aCallback);
	
	// constructors and destructor
	CTFLJourneyPlannerQuery();
	static CTFLJourneyPlannerQuery* NewL();
	static CTFLJourneyPlannerQuery* NewLC();        
	void ConstructL();
	virtual ~CTFLJourneyPlannerQuery();
							
	RTimer iTFLJourneyPlannerTimeoutTimer;
	LManagedPtr<scalp::CActiveTarget> iTFLJourneyPlannerTimeoutTarget;
	LManagedPtr<CHTTPTransactionSource> iTFLJourneyPlannerTransactionSource;
	LManagedPtr<CHTTPTransactionTarget> iTFLJourneyPlannerTransactionTarget;
	RHTTPTransaction iTFLJourneyPlannerTransaction;
	HBufC8* iStopOrigin;
	HBufC8* iStopDestination;
	TInt iTravelOption;
	TInt iTFLJourneyPlannerStatusCode;

	void TFLJourneyPlannerTransactionTimeoutL();
	
	void Cancel();
	
	TBool Pending() const;

	TInt TFLJourneyPlannerTransactionError(TInt aError, RHTTPTransaction aTransaction);
	void ReceivedTFLJourneyPlannerAnswerL(RHTTPTransaction aTransaction, THTTPEvent aEvent, TInt aLastError, TPtrC8 aBuf);
	
	};

#endif // __TFLJOURNEYPLANNERQUERY__
